//
//  OTDateItemCell.m
//  OT_OC
//
//  Created by yunmian on 2019/7/16.
//  Copyright © 2019 James. All rights reserved.
//

#import "OTDateItemCell.h"
#import "CalenderOTModel.h"

@interface OTDateItemCell ()
{
    UILabel             *titleLabel;
    UILabel             *durationLabel;
    UIView              *lineView;
}
@end

@implementation OTDateItemCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initUI];
    }
    return self;
}

- (void)initUI {
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    titleLabel = [[UILabel alloc] init];
    titleLabel.textColor = ColorHexFC3D42;
    [self.contentView addSubview:titleLabel];
    
    durationLabel = [[UILabel alloc] init];
    durationLabel.textColor = ColorHexFC3D42;
    durationLabel.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:durationLabel];
    
    lineView = [[UIView alloc] init];
    lineView.backgroundColor = ColorHexF5F5F5;
    [self.contentView addSubview:lineView];
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.offset(20);
    }];
    
    [durationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.offset(-20);
        make.height.offset(40);
//        make.left.offset(100);
    }];
    
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(10);
        make.right.offset(-10);
        make.bottom.offset(0);
        make.height.offset(1);
    }];
}

#pragma mark Event
- (void)onClickGroup {
    if ([self.delegate respondsToSelector:@selector(OTDateItemDidSelected:)]) {
        [self.delegate OTDateItemDidSelected:self];
    }
}

#pragma mark Set
- (void)setModel:(CalenderOTModel *)model {
    _model = model;
    
    titleLabel.text = model.OTDate;
    durationLabel.text = model.OTDuration;
}

@end
